Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix abbreviate weekday name. #470

Merged
merged 1 commit into from
Jan 31, 2024
Merged

Fix abbreviate weekday name. #470

merged 1 commit into from
Jan 31, 2024

Conversation

ACK1D
Copy link

@ACK1D ACK1D commented Dec 7, 2023

strftime("%a") expects a three letter abbreviation, so in current implementation two locations per week are closed.

@lb-
Copy link
Member

lb- commented Dec 7, 2023

This might fix #298

@ACK1D
Copy link
Author

ACK1D commented Dec 17, 2023

This might fix #298

Yeah, that solves that issue.

Copy link
Member

@lb- lb- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ACK1D this works well for new data but did not work well for existing bakerydemo installations.

I have added migration functions and will push to your branch.

https://docs.djangoproject.com/en/5.0/ref/migration-operations/#runpython

def forwards_func(apps, schema_editor):
    OperatingHours = apps.get_model("locations", "locationoperatinghours")
    db_alias = schema_editor.connection.alias
    OperatingHours.objects.using(db_alias).filter(day="TUES").update(day="TUE")
    OperatingHours.objects.using(db_alias).filter(day="THUR").update(day="THU")


def reverse_func(apps, schema_editor):
    OperatingHours = apps.get_model("locations", "locationoperatinghours")
    db_alias = schema_editor.connection.alias
    OperatingHours.objects.using(db_alias).filter(day="TUE").update(day="TUES")
    OperatingHours.objects.using(db_alias).filter(day="THU").update(day="THUR")

# ...
    operations = [
        migrations.RunPython(forwards_func, reverse_func), # added here
        migrations.AlterField(
            model_name="locationoperatinghours",
    # ...

@lb- lb- merged commit a171a4b into wagtail:main Jan 31, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants